package com.eliota.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/*
* 接口统一返回包装类
* */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private String code;
    private String msg;
    private Object data;

    private static final String ERROR_CODE = "-1";

    public static R success() {
        return new R(Constants.CODE_200, "",null);
    }

    public static R success(Object data) {
        return new R(Constants.CODE_200, "", data);
    }

    public static R error(String code, String msg){
        return new R(code, msg,null);
    }

    public static R error(){
        return new R(Constants.CODE_500, "系统错误",null);
    }


    public static R error(String msg) {
        return new R();
    }
    public static R success(Object data,String msg){
        return new R(Constants.CODE_200,msg,data);
    }

}
